import { defineAsyncComponent } from 'vue'
export { confirm } from './confirm/index'
export { message } from './message/index'

const libs = {
  install(app) {
    // app.component('z-svg-icon', svgIcon)
    // app.component('z-popup', popup)
    // 1.获取当前路径下所有文件夹中的 index.vue 文件
    const components = import.meta.glob('./**/index.vue')
    // 2.遍历获取到的组件模块
    for (const [fullPath, fn] of Object.entries(components)) {
      // 注册组件
      const componentName = 'z-' + fullPath.split('/')[1]
      // 3.动态导入组件
      app.component(componentName, defineAsyncComponent(fn))
    }
  }
}

export function setupLibs(app) {
  app.use(libs)
}
